import { defineStore } from "pinia"
import { getAllCity } from "@/api"

export const useCityStore = defineStore("city", {
  state() {
    return {
      allCity: {},
      // 当前城市信息
      currentCityData: {}
    }
  },
  actions: {
    // 获取所有城市数据
    async fetchAllcityData() {
      const res = await getAllCity()
      this.allCity = res.data
    },
    // 修改当前城市数据
    changeCurrentCityData(city) {
      this.currentCityData = city
    }
  }
})